import Vue from 'vue'
import Router from 'vue-router'		//路由模块
import Home from './views/Home.vue'	//主页组件
import Mine from './views/Mine.vue'	//我的组件

import Playing from './views/Playing.vue'
import Comming from './views/Comming.vue'

// Vue.use()	 添加模块，增加功能
Vue.use(Router)

// 单页应用 single page app ( SPA )

export default new Router({
//mode: 'history',
//base: process.env.BASE_URL,
  routes: [					//路由配置	( 以往的页面 )
		{
			path:'/',redirect:"/home"
		},
    {
      path: '/home',				//只有/代表默认路径   /home  
      name: 'home',		  //命名路由 
      component: Home	,  //访问到路由时，渲染的组件 ( 页面 )	
      children:[
      		{path:"playing",component:Playing},
      		{path:"comming",component:Comming},
        		{path:"",redirect:"playing"}
    	  ]
    },
    {
      path: '/about/:id&:cinema_id',
      name: 'about',
      // route level code-splitting
      // this generates a separate chunk (about.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      
      //路由被访问时才进行加载 (路由懒加载) 打包时会分离对应的文件
      component: () => import(/* webpackChunkName: "about" */ './views/About.vue')
    },
    {
    	//动态路由
    	path:'/mine/:userId',				//(必选)
    	name:'mine',
    	component:function(){
    				return import('./views/Mine.vue');
    	}			//(必选)
    },
    
    	{
    		path:'/movie/:movieId',
    		name:'movie',
    		component: ()=>import('./views/Movie.vue')
    	}
    
  ]
})
